package com.customization.unionpay.market.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import weaver.backup.logging.Logger;
import weaver.backup.logging.LoggerFactory;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class RequestUtil {

    public static final Logger log = LoggerFactory.getLogger(RequestUtil.class);

    public static JSONObject dealPostRequest(HttpServletRequest request){
        StringBuilder sb = new StringBuilder();
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
            String line;
            while ((line = reader.readLine()) != null) {
                sb.append(line);
            }
        }catch (Exception e){
              log.error("请求参数解析错误");
        }
        String json = sb.toString();
        return JSON.parseObject(json);
    }
}
